<template>
  <!-- 收货启动,记录卸货人 -->
		<div class="ywshouhuo_xhr">

			<van-nav-bar :fixed="true" class="navBar" title="收货启动" left-arrow @click-left="$router.go(-1)"></van-nav-bar>

				<div class="goodsFromWarp">
						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">入库标签：</div>
								</div>

								<van-field
									 class="skuInput"
									 v-model="editForm.shserno_s"
									 placeholder="请填写入库标签"
								 />

								<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="searchGoodsBtn()" >
										<van-icon name="ellipsis" color="#1989fa"  />
									</button>
								</div>
						</div>


						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">商品编码：</div>
								</div>
								<div class="skuNoInput">
									{{editForm.itemid}}
								</div>
						</div>


						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">商品名称：</div>
								</div>
								<div class="skuNoInput">
									{{editForm.subsname}}
								</div>
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">箱装：</div>
								</div>
								<div class="skuNoInput">
									{{editForm.unit}}
								</div>
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">箱数：</div>
								</div>
								<div class="skuNoInput">
									{{editForm.pack}}
								</div>
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">散数：</div>
								</div>
								<div class="skuNoInput">
									{{editForm.qty}}
								</div>
						</div>




						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">目标仓位：</div>
								</div>
								<van-field
									 class="skuInput"
									 v-model="editForm.cwno"
									 placeholder="请填写目标仓位"
								 />
						</div>





				</div>














				<div class="skuBtn">
					<van-button type="info" :disabled="isdisabled" @click="_getQucangClick()">取建议仓</van-button>
					<van-button type="info" :disabled="isdisabled" @click="saveShangJiaBtn()">确认</van-button>
				</div>
		</div>

</template>

<script>
import { mapActions } from "vuex";
export default {
  name: 'shouhuoqidong',
  data () {
    return {
			editForm:{
				shserno_s:'', //入库标签
				itemid:'',  //商品编码
				subsname:'',  //商品名称
				unit:'', //箱装
				pack:'', //箱数
				qty:'', //散数
				hqid:'', //货区
				p_date:'', //生产日期
				bill:'', //入库单号
				billtype:'', //单据类型
				cwno:'', //上架仓位
			},
			selectBillsVisible:false,
			isdisabled:false,
			yujianTable:[],
			timeoutId: null,
			danjuhuizong:{},
			skuData:{},
			selectSkuVisible:false,
			shouHuoData:[],
			selectShuoHuoDanVisible:false,
    }
  },
  methods: {
		 ...mapActions(["showLoading", "hideLoading"]),
		 searchGoodsBtn(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_shouhuo',
				'i':this.FNULLE([
					'opmode','SHSJ_qrybq',
					'kqid', this.ryuser.kqid,
					'shserno_s',this.editForm.shserno_s,
				])
				}, '入库标签查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}

					_self.skuData = rtn_json_obj
					console.log("得到商品条码")
					console.log(_self.skuData)
					if(_self.skuData.length > 0){
							_self.editForm.itemid 	= _self.skuData[0].itemid
							_self.editForm.subsname = _self.skuData[0].subsname
							_self.editForm.unit 		= _self.skuData[0].unit
							_self.editForm.pack 		= _self.skuData[0].pack
							_self.editForm.qty		 	= _self.skuData[0].qty
							_self.editForm.hqid 		= _self.skuData[0].hqid
							_self.editForm.p_date 	= _self.skuData[0].p_date
							_self.editForm.bill 		= _self.skuData[0].bill
							_self.editForm.billtype = _self.skuData[0].billtype
					}else{
						_self.$toast.fail('暂无商品详情')
					}
				}
			 });
		 },
		 _getQucangClick(){
			 console.log(this.editForm)
			 console.log(this.ryuser)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_shouhuo',
					'i':this.FNULLE([
						'opmode','SHSJ_qryjycwno',
						'kqid', this.ryuser.kqid,
						'shserno_s',this.editForm.shserno_s,
						'czyid',this.ryuser.operatorid,
					])
					}, '取仓建议',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}

						console.log("得到仓位")
						console.log(rtn_json_obj)
						_self.editForm.cwno = rtn_json_obj[0].ret_mess
					}
			 });
		 },
		 saveShangJiaBtn(){
			 console.log(this.editForm)
			 console.log(this.ryuser)
			 var _self = this;
			 // _self.isdisabled  = true
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_shouhuo',
					'i':this.FNULLE([
						'opmode','SHSJ_qrcwno',
						'kqid', this.ryuser.kqid,
						'shserno_s',this.editForm.shserno_s,
						'cwno',this.editForm.cwno,
						'czyid',this.ryuser.operatorid,
						'bill',this.editForm.bill,
						'billtype',this.editForm.billtype,
					])
					}, '上架仓位',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					 // _self.isdisabled  = false
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						// _self.isdisabled  = false
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}

						console.log("得到上架仓位")
						console.log(rtn_json_obj)
						if(rtn_json_obj[0].ret_ret == '-1'){
							_self.$toast.fail(rtn_json_obj[0].ret_mess)
						}else{
							_self.editForm.itemid 	= ''
							_self.editForm.shserno_s 	= ''
							_self.editForm.subsname = ''
							_self.editForm.unit 		= ''
							_self.editForm.pack 		= ''
							_self.editForm.qty		 	= ''
							_self.editForm.hqid 		= ''
							_self.editForm.p_date 	= ''
							_self.editForm.bill 		= ''
							_self.editForm.billtype = ''
							_self.editForm.cwno = ''
							_self.$toast(rtn_json_obj[0].ret_mess)
						}
					}
			 });
		 },
  },
  components:{

  },
  computed: {
     ryuser: function(){
       return this.GWO(true).gUSER;
     }
  },
  mounted :function(){
    var _self = this; window.GWO().debug=this;
  }
}

</script>
<style scoped lang="scss">
// 引入公共样式
@import '@/assets/css/base.scss';
@import '@/assets/css/input.scss';
.ywshouhuo_xhr{
	padding-top:50px;
	padding-bottom: 50px;
}
</style>

